import java.util.Arrays;

public class J07nosure {
    public static void main(String[] args) {
        f1(1,3,5);
        f1(66,77,11,33,44);
        System.out.println("======");
        f2();
        f2(true,67,88);
    }
    //参数不确定,不定参数，必须放在最后
    public static void f1(int... a){
        System.out.println("a = " + a);
        System.out.println(a.length);
        System.out.println(Arrays.toString(a));
    }
    public static void f2(){
    }
    public static void f2(boolean b1,int... x){
        System.out.println("b1 = " + b1);
        System.out.println("x = " + Arrays.toString(x));
    }
}

class CalacTest{
    public static void main(String[] args) {
        //true，加法
        //false，乘法
        System.out.println(calculate(true,3,4,5));//12
        System.out.println(calculate(false,3,4,5));//60

    }

    public static int calculate(boolean isAdd,int... numArr){
        if(isAdd==true){
            //加法
            int sum = 0;
            for (int i = 0; i < numArr.length; i++) {
                sum+=numArr[i];
            }
            return sum;
        }else{
            //乘法
            int by = 1;
            for (int i = 0; i < numArr.length; i++) {
                by*=numArr[i];
            }
            return by;
        }
    }
}
